﻿using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZR.Infrastructure.Filters
{
    public class StringToBoolBinderProvider : IModelBinderProvider
    {
        public IModelBinder? GetBinder(ModelBinderProviderContext context)
        {
            if (context.Metadata.ModelType == typeof(bool) ||
                context.Metadata.ModelType == typeof(bool?))
            {
                return new StringToBoolBinder();
            }
            return null; // 非目标类型则交由其他Provider处理
        }
    }

}
